package parser

import (
	"demo02/crawler/engine"
	"regexp"
)

const cityListRe = `<a href="(http://www.zhenai.com/zhenghun/[a-z0-9]+)"[^>]*>([^<]+)</a>`

func ParseCityList(content []byte) engine.ParseRequest {
	re := regexp.MustCompile(cityListRe)

	matches := re.FindAllSubmatch(content, -1)
	result := engine.ParseRequest{}
	for _, m := range matches {
		result.Items = append(result.Items, string(m[2]))
		result.Requests = append(result.Requests, engine.Request{
			Url:        string(m[1]),
			Code:       "gbk",
			ParserFunc: ParseCity,
		})
		break
	}
	return result
}
